<template>
    <h1>data</h1>
    <p>{{ name }}</p>
    <h1>props</h1>
    <p>{{ title }}</p>
    <button @click="test">点击</button>
    <p>num:{{ num }}</p>
    <button @click="add">+1</button><br>
    <p>num2:{{ num2 }}</p>
</template>

<script>
 export default{
    data(){
        return{
            name:"唐僧",
            num:1,
            num2:1,
        }
    },
    computed:{
      num2(){
        return this.num+1;
      }
    }, 
    watch:{
        num:function(newvlal,oldval){
            console.log('newvlal',newvlal);
            console.log('oldval',oldval);
           }
    },
    props:{
        title:{
            type:String,
            required:true,
            default:"这是默认的值"
        }
    },
    methods:{
        test(){
            console.log(123);
            console.log(this.name);
            this.name="猴哥";
            this.test1();
        },
        test1(){
            console.log(456);
               },
        add(){
             this.num=this.num+1;
             console.log(num);
             }
    }
 }
</script>